-
-
Notifications
You must be signed in to change notification settings - Fork 11
Add types for IPv4, IPv6 and variants, including CIDR notation #37
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add these CIDR types to stdlib instead?
For tests you can have a look at theforeman/puppet-dhcp@7d31525 but maybe rspec-puppet needs infrastructure to verify data types as well.
@@ -0,0 +1,2 @@ | |||
# https://stackoverflow.com/a/190405/1000630, with minor modifications to syntax | |||
type Tea::IPv4 = Pattern[/((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.|$)){4}/] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,2 @@ | |||
# Unsure where this came from, thank you Internet! | |||
type Tea::IPv6 = Pattern[/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/] # lint:ignore:140chars |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,2 @@ | |||
# https://stackoverflow.com/a/190405/1000630, with minor modifications to syntax | |||
type Tea::IP = Variant[Tea::IPv4, Tea::IPv6] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, adding them to stdlib would make sense. I talked a bit with @igalic about this at cfgmgmtcamp and I think we decided to start here, but having it in stdlib would be better. ...but in that case, why not move all types from tea into stdlib?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's entirely valid and this is partially already the case.
I can see that stdlib has added IP validation types (puppetlabs/puppetlabs-stdlib@6dad21e), so I'll close this one. |
\o/ |
Fixes #2
(I'm not opposed to adding tests, but I'd like a pointer to how to get there fast. I can see that stdlib uses the modulesync stuff, should this do the same?)